﻿// See https://aka.ms/new-console-template for more information
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using SqlSugar;

string path = @"C:\Users\DKE\Desktop\execl\草药.xlsx";

SqlSugarScope _Db = new SqlSugarScope(new List<ConnectionConfig>() {
        new ConnectionConfig()
        {
            ConnectionString = "Server=59.36.212.88;Database=Docking_Data;User ID=sa;Password=Iso14644;TrustServerCertificate=true;MultipleActiveResultSets=true",
            DbType = DbType.SqlServer,
            IsAutoCloseConnection = true,
            ConfigId="dock"
        }
        });
ISqlSugarClient _dock = _Db.GetConnectionScope("dock");

FileStream fs2 = File.OpenRead(path);

using (FileStream fs = File.OpenRead(path))
{
    HSSFWorkbook wk = new HSSFWorkbook(fs);//读取xls文件中的数据写入wk中
    ISheet sheet = wk.GetSheetAt(0); //读取当前表数据
    List<her> result = new();
    for (int j = 1; j <= sheet.LastRowNum; j++) //LastRowNum 最后一行的索引,从0开始
    {
        IRow row = sheet.GetRow(j);//获取当前行数据
        her obj = new();
        obj.Sign = row.Cells[0].StringCellValue;
        obj.Name = row.Cells[2].StringCellValue;
        result.Add(obj);
    }
    var s = 1;
}

internal class her
{
    public string Sign { get; set; }
    public string Name { get; set; }
}